{{extend 'layout.html'}}

{{=XML(add.formModal())}}
<div id="snmp_list">
    <div id="snmpbtns" class="navbar btn-toolbar">
        {{=XML(add.btn_show())}}
        <a id="delete_snmp" class="btn btn-small"><i class="icon-remove"></i> Delete</a>
        <a id="reload_snmp" class="btn btn-small" onclick="javascript:snmptable.fnReloadAjax(); return false;"><i class="icon-refresh"></i> Reload</a>
    </div>
    {{=table}}
</div>

<script>
var snmptable;

jQuery(document).ready(function() {

    $("#delete_snmp").click(function(e) {
        e.preventDefault();

        //bootbox.options.onEscape =
        var checks = dt_checkboxer_select_DT_RowIds(snmptable);
        if (checks == '') { alert('Nothing selected'); return false; }

        bootbox.confirm('These items will be permanently deleted and cannot be recovered. Are you sure?', "Cancel", "Delete", function(confirmed) {
            if(confirmed) {
                var data = "ids=" + checks;
                url = "{{=URL('snmp', 'delete.json', user_signature=True)}}";
                $.web2py.ajax_page( 'POST', url, data, 'undefined' );
            }
        });
    });

    snmptable = jQuery('#snmptable').dataTable( {
        "sDom": 'T<"clear"><"checkboxer-min">lfrtip',
        "oTableTools": {
            "sRowSelect": "multi",
            "sSelectedClass": "row_selected",
            "sSwfPath": "{{=URL('static', 'TableTools/swf/copy_csv_xls.swf')}}"
        },
        "sAjaxSource": "{{=URL('snmp', 'list.json')}}",
    } );
} );
</script>
